{% macro simple(paginator) %}
    {{ pagerfanta(paginator, 'twig', options|default({'template': '@SyliusAdmin/shared/pagerfanta.html.twig'})) }}
{% endmacro %}

{% macro results_count(paginator) %}
    {% set from = 1 + (paginator.currentPage - 1) * paginator.maxPerPage %}
    {% set to = paginator.maxPerPage + (paginator.currentPage - 1) * paginator.maxPerPage %}
    {% set to = to < paginator.nbResults ? to : paginator.nbResults %}

    {{ 'sylius.ui.pagination.number_of_results'|trans({'%from%': from, '%to%': to, '%total%': paginator.nbResults}) }}
{% endmacro %}

{% macro number_of_results_selector(paginator, pagination_limits) %}
    {% set other_pagination_limits = pagination_limits|filter(limit => limit != paginator.maxPerPage) %}

    {% if other_pagination_limits is not empty %}
        <div class="dropdown">
            <button type="button" class="btn dropdown-toggle" data-bs-toggle="dropdown">
                {{ 'sylius.ui.show'|trans }} {{ paginator.maxPerPage }}
            </button>
            <div class="dropdown-menu dropdown-menu-end ">
                {% for limit in other_pagination_limits %}
                    {% set path = path(app.request.attributes.get('_route'), app.request.attributes.all('_route_params')|merge(app.request.query)|merge({'limit': limit})) %}
                    <a class="dropdown-item" href="{{ path }}">{{ limit }}</a>
                {% endfor %}
            </div>
        </div>
    {% else %}
        <button type="button" class="btn btn-ghost-secondary dropdown-toggle" disabled>
            {{ 'sylius.ui.show'|trans }} {{ paginator.maxPerPage }}
        </button>
    {% endif %}
{% endmacro %}
